home *** CD-ROM | disk | FTP | other *** search
/ Internet Tools (InfoMagic) / Internet Tools.iso / security / securelib.README < prev    next >
Text File  |  1993-12-16  |  11KB  |  269 lines

  1. SunOS 4.1 secure C library package
  2.  
  3. Written by William LeFebvre, EECS Department, Northwestern University.
  4. Internet address: phil@eecs.nwu.edu
  5.  
  6. Code for reading the configuration file, along with a few important
  7. patches, was provided by Sam Horrocks of UCI (sam@ics.uci.edu).
  8.  
  9. OVERVIEW:
  10.  
  11. This package contains replacement routines for these three kernel
  12. calls: accept, recvfrom, recvmsg.  These replacements are compatible
  13. with the originals, with the additional functionality that they check
  14. the Internet address of the machine initiating the connection to make
  15. sure that it is "allowed" to connect.
  16.  
  17. Once compiled, these can be used when building a new shared libc.  The
  18. resulting libc.so can then be put in a special place.  Any program
  19. that should be protected can then be started with an alternate
  20. LD_LIBRARY_PATH.
  21.  
  22. What you need:
  23.         SunOS version 4.1, 4.1.1, or 4.1.2 (or 4.1.3 if there ever is one),
  24.         installation of the "shared library" option,
  25.         root access.
  26.  
  27. SunOS 5 (Solaris 2.0) users are on your own.  I have no idea if this
  28. will work with version 5 or its successors.
  29.  
  30. You can see if your machine has the shared library option installed by
  31. looking for the directory "/usr/lib/shlib.etc".  If it is not
  32. installed, then you will need to extract it from the distribution
  33. tapes (Sun-factory installed machines will NOT have it installed).
  34.  
  35. Do you need to use this?  If you can answer all of these questions
  36. with "yes", then this package will benefit you:
  37.  
  38.         Are you connected to the Internet (even via a local or
  39.         regional network)?
  40.  
  41.         Do all of the routers/gateways between your machine and the
  42.         "rest of the world" route all packets regardless of protocol
  43.         or port number?
  44.  
  45.         Are you concerned about the fact that any user on any system
  46.         anywhere on the Internet can connect to any network daemon
  47.         that runs on your machine, including ypserv and pwdauthd?
  48.  
  49. AVAILABILITY:
  50.  
  51. The latest version of securelib is available via anonymous FTP from
  52. the host "eecs.nwu.edu".  It is stored in the file "pub/securelib.tar".
  53. Remember to use the "binary" transfer mode!
  54.  
  55. DETAILS:
  56.  
  57. Each modified system call has the same basic algorithm:
  58.  
  59. {
  60.         int retval;
  61.  
  62.         if ((retval = syscall(...)) >= 0)
  63.         {
  64.                 if (_ok_address(socket, addr, *addrlen))
  65.                 {
  66.                         return (retval);
  67.                 }
  68.                 close(retval); /* this line: "accept" only */
  69.                 errno = ECONNREFUSED;
  70.                 return (-1);
  71.         }
  72.         return (retval);
  73. }
  74.  
  75. Connections that are established from a host that is not "okay" will
  76. be closed (if established via "accept"), then errno will be set to
  77. ECONNREFUSED and the calling application will get an error indication
  78. back from its system call.  It is assumed that the application will
  79. deal with such an error in an intelligent fashion.  All Sun daemons
  80. that we have tried seem to handle this correctly: they merely do the
  81. system call again.
  82.  
  83. The application will only see success for machines that "_ok_address"
  84. says are acceptable.  All other connections look like failures.
  85.  
  86. The function "_ok_address" reads a configuration file (normally
  87. "/etc/securelib.conf" or "/etc/security/securelib.conf") which
  88. describes what Internet address are acceptable.
  89.  
  90. CONFIGURATION FILE:
  91.  
  92. The configuration file (usually /etc/securelib.conf) is read by every
  93. process using securelib to find out which hosts are allowed to make
  94. connections.  Every hour, the config file is stat'ed to see if it has
  95. changed.  If it has, the file is re-read.
  96.  
  97. The first column in the file is the name of the process to which this
  98. line applies.  If this name is "all" then this line will apply to all
  99. processes using securlib on this host.  Otherwise, this name is
  100. checked against the environment variable "SL_NAME" to see if that's a
  101. match.  If it does match, then the line is taken to apply to the
  102. current process.
  103.  
  104. The mask field (the last field on each line) is a set of bits which
  105. are taken out of the source host's address before further comparison.
  106. These are bits in the address which can be ignored.
  107.  
  108. The address field (the second field on each line) is the address which
  109. the source host's address must match in order for a connection to be
  110. successful.  The source address is only compared to this address after
  111. the bits specified by the mask field have been cancelled out.
  112.  
  113. For example, the line:
  114.  
  115. all     128.199.0.0     0.0.255.255
  116.  
  117. would apply to all programs using securelib and would allow
  118. connections from hosts whose address start with 128.199.
  119.  
  120. A host is allowed to connect if *any* of the lines in the config file,
  121. which apply to that process, give it access.  There is no way to
  122. specify a "deny" line which would cause unconditional rejection of
  123. certain addresses.
  124.  
  125. STARTING A SECURELIB PROCESS:
  126.  
  127. "make install" will install both the "start" script and the securelib
  128. shared library in the destination specified in Makefile (usually
  129. "/usr/lib/secure").  To start a process using securelib, use the
  130. command:
  131.  
  132.     /usr/lib/secure/start <program> <arguments>
  133.  
  134. This will pass the correct "SL_NAME" environment variable to the program and
  135. will set the correct LD_LIBRARY_PATH so that the program uses securelib.
  136.  
  137. SPECIAL NOTE TO SunOS 4.1.2 USERS:
  138.  
  139. There is essentially a bug in /usr/etc/shlib.etc/Makefile.  The line
  140. immediately following "libc.so:" looks like this:
  141.  
  142.         ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
  143.  
  144. It should look like this:
  145.  
  146.         ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
  147.  
  148. Although I have not actually tested securelib on a 4.1.2 system, I am
  149. fairly certain that you will need to make this change before securelib
  150. will compile and link successfully under 4.1.2.
  151.  
  152. INSTALLATION:
  153.  
  154. Create a file called "securelib.conf" in the source directory, using the
  155. file "securelib.conf.ex" as an example.  Be sure to tailor this file
  156. to your site's needs.  You should also make sure that you include a
  157. rule for the loopback network:
  158.  
  159. all             127.0.0.0       0.255.255.255
  160.  
  161. Edit the Makefile and make changes as appropriate to the definitions
  162. of SHLIB, DESTDIR, and CONFFILE.  SHLIB defines the location of Sun's
  163. shlib.etc directory as extracted from the installation tape.  This
  164. will almost certainly be "/usr/lib/shlib.etc".  DESTDIR is the
  165. directory in which you want the secure library (libc.so.X.X.X) and the
  166. "start" shell script installed.  CONFFILE is the full name of the
  167. installed configuration file.  The Makefile will set compile-time
  168. constants indicating the location of the configuration file, and it
  169. will also install "securelib.conf" from the current directory as the
  170. name specified by CONFFILE in the "make install" step.
  171.  
  172. The process of buliding the new shared library uses the Makefile in
  173. /usr/lib/shlib.etc.  Unfortunately, this Makefile assumes that "."
  174. is on your path.  Make sure that this is the case or the make will
  175. fail with a message like "objsort: not found".
  176.  
  177. Once you have made these changes, type "make install" and everything
  178. should go smoothly.  Typing just "make" will build the new library in
  179. the SHLIB directory, but it will not install it.
  180.  
  181. CHOOSING APPROPRIATE LOCATIONS:
  182.  
  183. Two good places for securelib.conf are "/etc" and "/etc/security".
  184. The advantage of placing it in "/etc/security" is that non-root users
  185. will not be able to determine which Internet addresses are accepted by
  186. the sensitive daemons.  This is an extra measure of security, similar
  187. to protecting /.rhosts.  However, the disadvantage is that use of the
  188. secure shared library is then restricted to only root processes (since
  189. only root can read the configuration file).  If you need non-root
  190. processes to use securelib, or if you do not feel a need to protect
  191. the information in the configuration file, then place the file in "/etc".
  192.  
  193. The location of the library itself is typically "/usr/lib/secure".
  194. There is no reasonable place to put the library in the Sun file system
  195. heirarchy, so I just invented a new directory.  REPLACING OR
  196. SUPERCEDING THE EXISTING libc LIBRARY IS NOT RECOMMENDED!!!  The
  197. intent of this package is to provide an alternate libc that can be
  198. used only on selected server processes (usually servers that are
  199. started at boot time).  The alternate library is selected by setting
  200. LD_LIBRARY_PATH before starting the server.
  201.  
  202. USING THE ALTERNATE LIBRARY:
  203.  
  204. Now decide which servers you want to protect.  I personally have
  205. chosen portmap, rpc.pwdauthd, ypserv, and rpc.yppasswdd.  Another
  206. possibility is nfsd, but remember that each packet received by nfsd
  207. must be verified by "_ok_address".  This may have a noticeable impact
  208. on nfs performance.
  209.  
  210. Modify /etc/rc.local so that it starts the daemon with the "start"
  211. script.  What I have done locally is put some code at the very
  212. beginning of rc.local to determine if the secure library is available
  213. on the system and set an environment variable accordingly:
  214.  
  215.         SECURE=""
  216.         if [ -x /usr/lib/secure/start ]; then
  217.                 SECURE="/usr/lib/secure/start"
  218.         fi
  219.  
  220. Now any daemon which I want to protect is started with a line like
  221. this:
  222.  
  223.         $SECURE portmap;                echo 'starting rpc port mapper.'
  224.  
  225. If the shell script does not exist on the machine being booted, then
  226. SECURE will be null and "$SECURE portmap" will expand to merely "portmap".
  227.  
  228. NOTE TO CUSTOM SHARED LIBRARY BUILDERS:
  229.  
  230. If you have already built a customized shared library, for example if
  231. you have built a shared library with alternate gethost* routines for
  232. name resolution, you can still use this package.  Just make sure that
  233. before you type "make", the object files for your alternate library
  234. are already in place in SHLIB/tmp.  If the "tmp" subdirectory already
  235. exists, then this package will not recreate it or re-extract
  236. libc_pic.a.  However, it WILL overwrite tmp/accept.o, tmp/recvfrom.o,
  237. and tmp/recvmsg.o.  And it will add a line to lorder-sparc (after
  238. saving the original in lorder-sparc.orig).
  239.  
  240. DISCLAIMERS:
  241.  
  242. IMPORTANT NOTE:  THIS LIBRARY DOES NOT GUARANTEE THAT YOUR MACHINE IS
  243. SECURE!!!  This library enhances security---it does not guarantee it.
  244. It can be used to plug several known security holes on machines running
  245. SunOS 4.1 and 4.1.x.
  246.  
  247. NO WARRANTY:
  248.  
  249. BECAUSE "securelib" IS DISTRIBUTED FREE OF CHARGE, THERE IS ABSOLUTELY
  250. NO WARRANTY PROVIDED, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.
  251. EXCEPT WHEN OTHERWISE STATED IN WRITING, NORTHWESTERN UNIVERSITY,
  252. WILLIAM N. LeFEBVRE AND/OR OTHER PARTIES PROVIDE "securelib" "AS IS"
  253. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  254. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  255. FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  256. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE "securelib"
  257. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  258. SERVICING, REPAIR OR CORRECTION.
  259.  
  260. IN NO EVENT WILL NORTHWESTERN UNIVERSITY, WILLIAM N. LeFEBVRE, AND/OR
  261. ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE "securelib", BE LIABLE
  262. TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
  263. SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  264. INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  265. BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  266. FAILURE OF THE PROGRAM TO OPERATE WITH OTHER PROGRAMS) THE PROGRAM,
  267. EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR
  268. FOR ANY CLAIM BY ANY OTHER PARTY.
  269.